import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import store from '@/store'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const base = (window as any).__POWERED_BY_QIANKUN__ ? '/vue-micro-app' : ''
store.commit('updateBaseUrl', base)

const routes: Array<RouteRecordRaw> = [
  {
    path: `${base}/`,
    name: 'home',
    component: HomeView
  },
  {
    path: `${base}/about`,
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(base),
  routes
})

export default router
